package com.yaosheng.thread.thread;

import java.util.concurrent.TimeUnit;

/**
 * Created by yaosheng on 2021/7/7.
 */
public class ThreadLocal2 {

    static ThreadLocal<String> threadLocal = new ThreadLocal<> ();

    public static void main(String[] args) {

        new Thread ( () -> {
            try{
                threadLocal.set ("姚圣");
                TimeUnit.SECONDS.sleep (2);
                System.out.println (threadLocal.get());
            } catch (InterruptedException e) {
                e.printStackTrace ();
            }
        }).start ();
    }
}
